import request from '@/config/axios'

// 库存预警信息 VO
export interface ProductMessageVO {
  id: number // id
  productId: number // 商品id
  message: string // 提示信息
  messageType: number // 0 低预警 1 高预警
}

// 库存预警信息 API
export const ProductMessageApi = {
  // 查询库存预警信息分页
  getProductMessagePage: async (params: any) => {
    return await request.get({ url: `/erp/product-message/page`, params })
  },

  // 查询库存预警信息详情
  getProductMessage: async (id: number) => {
    return await request.get({ url: `/erp/product-message/get?id=` + id })
  },

  // 新增库存预警信息
  createProductMessage: async (data: ProductMessageVO) => {
    return await request.post({ url: `/erp/product-message/create`, data })
  },

  // 修改库存预警信息
  updateProductMessage: async (data: ProductMessageVO) => {
    return await request.put({ url: `/erp/product-message/update`, data })
  },

  // 删除库存预警信息
  deleteProductMessage: async (id: number) => {
    return await request.delete({ url: `/erp/product-message/delete?id=` + id })
  },
  //生成采购单
  createPurchaseOrder: async (id: number) => {
    return await request.put({ url: `/erp/product-message/createPurchaseOrderByMessage?id=` + id })
  },

  // 导出库存预警信息 Excel
  exportProductMessage: async (params) => {
    return await request.download({ url: `/erp/product-message/export-excel`, params })
  }
}